<?php

/**
 * MVM_MALL 网上商店系统  弹窗管理
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-09-19 $
 * $Id: popup.inc.php www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL') || !defined('IN_ADMINCP')) exit('Access Denied');
if ($action=='list'){
    $result = $db->query("SELECT * FROM `{$tablepre}popup_table`");
    while ($rt= $db->fetch_array($result)) {
        $rt['edit']       = "admincp.php?module=$module&action=edit&uid=$rt[uid]";
        $rt['del']        = "admincp.php?module=$module&action=del&uid=$rt[uid]";
        $rt['start_date'] = date($mm_date_format,$rt['start_date']);
        $rt['end_date']   = date($mm_date_format,$rt['end_date']);
    	$popup_rt[]       = $rt;
    }
    require_once template('popup');
    footer();
} elseif ($action=='add' || $action=='edit'){
    if($setp==1&&$_POST){
        $start_date = time_format($start_date );
        $end_date   = time_format($end_date);
        $row = array(
        'popup_left'       => $popup_left,
        'popup_top'        => $popup_top,
        'popup_height'     => $popup_height,
        'popup_width'      => $popup_width,
        'use_html'         => $use_html,
        'popup_subject'    => $popup_subject,
        'popup_main'       => $popup_main,
        'start_date'       => $start_date,
        'end_date'         => $end_date,
        'register_date'    => $m_now_time
        );
        is_numeric($uid) ? $db->update("{$tablepre}popup_table",$row,"uid='$uid'") : $db->insert("{$tablepre}popup_table",$row);
        admin_msg('success','admincp.php?module=popup&action=list');
    }else {
        if (is_numeric($uid)) {
            $rt = $db->get_one("SELECT * FROM `{$tablepre}popup_table` WHERE uid='$uid'");
            @extract($rt,EXTR_OVERWRITE);
            $start_date = date('Y-m-d',$start_date);
            $end_date   = date('Y-m-d',$end_date);
            drop_check($use_html,'use_html');
        }
        require_once template('popup_add');
        footer();
    }
} elseif ($action=='del' && is_numeric($uid)) {
    $db->query("DELETE FROM `{$tablepre}popup_table` WHERE uid='$uid'");
} else {
    admin_msg('pass_worng');
}